package com.kay.annotation.dao;

import com.kay.pojo.Order;
import com.kay.pojo.User;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Description:
 * @Author: Kay
 * @CreateDate: 2021/6/27$ 11:24$
 * @UpdateUser: Kay
 * @UpdateDate: 2021/6/27$ 11:24$
 */
public interface OrderAnnotationMapper {
    @Results({
            @Result(column = "id", property = "id"),
            @Result(column = "orderTime", property = "orderTime"),
            @Result(column = "total", property = "total"),
            @Result(column = "uid", property = "user", javaType = User.class,
                    one = @One(select = "com.kay.annotation.dao.UserAnnotationMapper.findById"))
    })
    @Select("select * from orders ")
    List<Order> findAllOrderUser();

    @Select("select * from orders where uid = #{uid}")
    List<Order> findByUid(Integer uid);
}
